{% extends "base.html" %}
{% load crispy_forms_tags %}

{% block title %}
    {% if form.instance.pk %}
        编辑图书: {{ form.instance.title }}
    {% else %}
        添加新图书
    {% endif %}
{% endblock %}

{% block content %}
<div class="card shadow-sm">
    <div class="card-header">
        <h2 class="mb-0">
            {% if form.instance.pk %}
                编辑图书
            {% else %}
                添加新图书
            {% endif %}
        </h2>
    </div>
    <div class="card-body">
        <form method="post" novalidate>
            {% csrf_token %}
            
            {{ form|crispy }}
            
            <div class="mt-4">
                <button type="submit" class="btn btn-primary">
                    <i class="fas fa-save"></i> 保存
                </button>
                <a href="{% url 'manage_book_list' %}" class="btn btn-secondary">
                    <i class="fas fa-times"></i> 取消
                </a>
            </div>
        </form>
    </div>
</div>
{% endblock %}